﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using XSTDZ.ERP.Application.DataContracts;
using XSTDZ.ERP.WebApp.ViewModel;
using System.Web.Mvc;
using XSTDZ.ERP.Core.Extentions;

// add by chenqiao 2013/8/10 22:37
namespace XSTDZ.ERP.WebApp.Models
{
    /// <summary>
    /// 产品类别
    /// </summary>
    public class ProductTypeModel
    {
        /// <summary>
        /// 递归所有组织机构和部门，返回给前台的liguer树控件
        /// </summary>
        /// <param name="orglst"></param>
        /// <param name="deptlst"></param>
        /// <returns></returns>
        public IList<OrgViewModel> GetProductTypes(IList<ProductTypeDto> productTypeList)
        {
            IList<OrgViewModel> productTypes = new List<OrgViewModel>();
            if (productTypeList == null)
            {
                return null;
            }
            productTypeList.Each(p => productTypes.Add(new OrgViewModel
            {
                id = p.ID.ToString(),
                text =p.TypeName,
                isorg =p.ID==p.ParentID? "1":"0",
                isexpand=false,
                ischecked = false,
                icon = @XSTDZ.ERP.Infrastructure.SystemConfig.orgIcon
            }));
            return productTypes;
        }
       
    }
       
}